package com.school.controller;

import com.school.entity.PublicityTime;
import com.school.service.PublicityTimeService;
import com.school.untils.ResultEntity;
import com.school.untils.ResultUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@Api(tags = "公示时间管理")
@RestController
@RequestMapping("/publicityTime")
public class PublicityTimeController {
    @Autowired
    PublicityTimeService publicityTimeService;

    // 新增
    @ApiOperation("公示时间增加")
    @RequestMapping(value = "/add",method = RequestMethod.POST)
    public ResultEntity addPublicityTime(@RequestBody PublicityTime publicityTime){
        return ResultUtils.build(publicityTimeService.addPublicityTime(publicityTime));
    }

    // 更新
    @ApiOperation("公示时间更新")
    @RequestMapping(value = "/update",method = RequestMethod.POST)
    public ResultEntity updatePublicityTime(@RequestBody PublicityTime publicityTime){
        return ResultUtils.build(publicityTimeService.updatePublicityTime(publicityTime));
    }

    // 根据id查看详情
    @ApiOperation("公示时间查看详情")
    @GetMapping("/getDetailsById/{id}")
    public ResultEntity getDetailsById(@PathVariable("id") String id){
        return ResultUtils.build(publicityTimeService.getDetailsById(id));
    }

    // 根据id删除
    @ApiOperation("公示时间信息删除")
    @DeleteMapping("/delete/{id}")
    public void deletePublicityTime(@PathVariable("id") String id){
        publicityTimeService.deletePublicityTime(id);
    }

    // 根据id批量删除
    @ApiOperation("公示时间批量删除")
    @DeleteMapping("/batch")
    public void deletePublicityTimeList(String idList){
        publicityTimeService.deletePublicityTimeList(idList);
    }

    // 根据条件分页查询
    @ApiOperation("根据条件分页查询")
    @GetMapping("/specificPage")
    public ResultEntity specificPageQueryPublicityTimeList(PublicityTime publicityTime, @RequestParam int page, @RequestParam int size){
        return ResultUtils.build(publicityTimeService.specificPageQueryPublicityTimeList(publicityTime,page,size));
    }
}
